//
//  HSAwardListVM.m
//  HolyShit
//
//  Created by Robin on 2017/3/31.
//  Copyright © 2017年 HolyShit. All rights reserved.
//

#import "HSAwardListVM.h"

@implementation HSAwardListVM

- (RACCommand *)refreshCommand
{
    if (!_refreshCommand) {
        @weakify(self);
        _refreshCommand = [RACCommand commandWithSignalBlock:^RACSignal *(id input) {
            @strongify(self);
            NSString *url = @"http://www.59cp.com/api/Public/prizeShow";
            return [[MYHttpHelper shareHelper] rac_getWithUrl:url params:nil success:^(NSDictionary *dict) {
                @strongify(self);
                self.topics = @[].mutableCopy;
                if ([dict[@"errcode"] integerValue] == 0) {
                    HSAwardListModel *list = [HSAwardListModel modelWithDictionary:dict[@"typeList"]];
                    self.topics = list.hasCate.mutableCopy;
                    [self.topics.lastObject.subInfo enumerateObjectsUsingBlock:^(HSSubInfoModel * _Nonnull obj, NSUInteger idx, BOOL * _Nonnull stop) {
                        obj.prizeInfo.isKuai3 = YES;
                    }];
                    HSCateModel *cate = [HSCateModel new];
                    cate.subInfo = list.noCate;
                    [self.topics addObject:cate];
                }
            } failed:^(NSError *error) {
                
            }].racSignal;
        }];
    }
    return _refreshCommand;
}

@end
